package com.school.component;

import com.school.activity.R;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MyDialog extends Dialog{

	private MyDialog myDialog;
	private String title;
	private String message;
	private String negativeButtonText;
	private Button button;
	private android.view.View.OnClickListener onClickListener;
	public MyDialog(Context context) {
		super(context);
	}

	public MyDialog(Context context,String title,String message,String negativeButtonText,android.view.View.OnClickListener onClickListener){
		super(context,R.style.MyDialog);
		myDialog=this;
		this.title=title;
		this.message=message;
		this.negativeButtonText=negativeButtonText; 
		this.onClickListener=onClickListener;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.mydialog);
		((TextView)findViewById(R.id.mydialog_title)).setText(title);
		((TextView)findViewById(R.id.mydialog_message)).setText(message);
		button=(Button)findViewById(R.id.mydialog_btn_ok);
		button.setText(negativeButtonText);
		if(onClickListener==null){
			button.setOnClickListener(new android.view.View.OnClickListener() {
				@Override
				public void onClick(View v) {
					myDialog.cancel();
				}
			});
		}else{
			button.setOnClickListener(onClickListener);
		}
	}
	public MyDialog(Context context, int theme){
		super(context, theme);
	}
}
